"""
@author: XDing
@file: 三乐购物系统.py
@time: 2023/3/29 21:18
"""
commodity = []
shoppingCart = []

# 商品列表
def commoditylist():
    print("商品名称 商品价格 商品编号")
    for i in commodity:
        print("%s %s %s" % (i["name"], i["price"], i["id"]))

# 购物车
def shoppingCartList():
    name,price,id,number = input("商品名称 商品价格 商品编号 商品数量")
    for i in shoppingCart:
        print("%s %s %s %s",(i["name"], i["price"], i["id"], i["number"]))

# 输出总金额
def bill():
    shoppingCartList()
    total = 0
    for i in shoppingCart:
        total += int(i["price"]) * int(i["number"])
    print("总金额：%s",total)

# 退出
def Exit():
    exit()


# 菜单
def Menu():
    print("超市购物车")
    print("1.商品列表")
    print("2.购物车")
    print("3.结算")
    print("4.退出")

def Main():
    while True:
        Menu()
        choice = input("请输入您的选择：")
        if choice == "1":
            commoditylist()
        elif choice == "2":
            shoppingCartList()
        elif choice == "3":
            bill()
        elif choice == "4":
            Exit()
        else:
            print("输入错误！")

if __name__ == '__main__':
    Main()